﻿using System.Collections.Generic;
using System.Linq;

namespace ExcelAutomator.Validation
{
	public class ValidationReport
	{
		private readonly IEnumerable<IValidationResult> m_ValidationResults;

		public ValidationReport(IEnumerable<IValidationResult> validationResults)
		{
			m_ValidationResults = validationResults;
		}

		public bool IsValid
		{
			get { return m_ValidationResults.All(result => result.IsValid == true); }
		}

		public int ViolationsCount
		{
			get { return Violations.Count(); }
		}

		public IEnumerable<IValidationResult> Violations
		{
			get { return m_ValidationResults.Where(v => v.IsValid == false).DistinctBy(x=>x.ToString()); }
		}

		public IEnumerable<IValidationResult> ValidResults
		{
			get
			{
				return m_ValidationResults.Where(v => v.IsValid == true);
			}
		}

		public IEnumerable<IValidationResult> Results
		{
			get
			{
				return m_ValidationResults;
			}
		}
	}
}
